package designpatterns.iterator;

import java.util.List;

public class Iterator1 implements Iterator {
    private List<Object> list = null;
    private int index = -1;

    public Iterator1(List<Object> list) {
        this.list = list;
    }

    @Override
    public Object first() {
        this.index = 0;
        return list.get(index);
    }

    @Override
    public Object next() {
        Object ret = null;
        if(this.hasNext()) {
            ret = list.get(++ index);
        }
        return ret;
    }

    @Override
    public boolean hasNext() {
        return index < list.size() - 1;
    }
}
